﻿namespace UsingClassesAndObjects
{
    using System;

    class WorkDaysCount
    {
        // 1.2.10.05. Write a method that calculates the number of workdays between today and given date,
        // passed as parameter. Consider that workdays are all days from Monday to Friday except a fixed
        // list of public holidays specified preliminary as array.

        static void Main()
        {
            //Console.Write("Enter day: ");
            int day = 3;// int.Parse(Console.ReadLine());

            //Console.Write("Enter month: ");
            int month = 2;//int.Parse(Console.ReadLine());

            //Console.Write("Enter year: ");
            int year = 2014;// int.Parse(Console.ReadLine());

            DateTime today = DateTime.Today;
            DateTime endPeriod = new DateTime(year, month, day);
            TimeSpan daysPeriod = endPeriod - today;

            DateTime[] holidays =
            {
                new DateTime(2014, 1, 5),
                new DateTime(2014, 1, 8),
                new DateTime(2014, 1, 21),

            };

            int workDaysCounter = 0;
            bool isWorkDay = true;
            for (int i = 0; i < daysPeriod.Days; i++)
            {
                for (int j = 0; j < holidays.Length; j++)
                {
                    if (today.DayOfWeek == DayOfWeek.Saturday || today.DayOfWeek == DayOfWeek.Sunday || (holidays[j].Month == today.Month && holidays[j].Day == today.Day))
                    {
                        isWorkDay = false;
                    }
                }

                if (isWorkDay == true)
                {
                    workDaysCounter++;
                }

                isWorkDay = true;
                today.AddDays(1);
            }

            Console.WriteLine(workDaysCounter);
        }
    }
}